home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
HyperCard Goodies
/
HyperCard Dev. ToolKit
/
Serial & MacinTalk XCMDs
/
recvPort.p
< prev
next >
Wrap
Text File
|
1987-07-15
|
1KB
|
69 lines
{$R-}
(*
recvSPort(port number) -- Return a character from the serial port.
To compile and link this file using Macintosh Programmer's Workshop,
pascal -w recvPort.p
link -m ENTRYPOINT -o HyperCommands -rt XFCN=1 -sn Main=recvSPort recvPort.p.o "{MPW}"Libraries:interface.o
*)
{$S recvSPort } { Segment name must be the same as the command name. }
unit DummyUnit;
interface
uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
procedure EntryPoint(paramPtr: XCmdPtr);
implementation
type
Str31 = String[31];
procedure recvSPort(paramPtr: XCmdPtr); forward;
procedure EntryPoint(paramPtr: XCmdPtr);
begin
recvSPort(paramPtr);
end;
procedure recvSPort(paramPtr: XCmdPtr);
var portNumber: integer;
inPort: integer;
str: Str255;
l: longInt;
{$I XCmdGlue.inc}
procedure Fail(errMsg: Str255); { set theResult and quit }
begin
paramPtr^.returnValue := PasToZero(errMsg);
exit(recvSPort);
end;
begin
if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
ZeroToPas(paramPtr^.params[1]^,str); { First parameter is port number. }
portNumber := StrToNum(str);
if (portNumber < 1) or (portNumber > 2) then Fail('invalid port number');
if portNumber = 1 then inPort := -6
else inPort := -8;
l := 1;
str[0] := chr(1);
if FSRead(inPort,l,Ptr(ord4(@str)+1)) <> noErr then Fail('FSRead failed');
if l <> 1 then str[0] := chr(0);
paramPtr^.returnValue := PasToZero(str);
end;
end.